package com.linb.pan.server;

import com.linb.pan.core.constants.BPanConstants;
import com.linb.pan.core.response.R;
import com.linb.pan.server.common.stream.channel.PanChannels;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

@SpringBootApplication(scanBasePackages = BPanConstants.BASE_COMPONENT_SCAN_PATH)
@ServletComponentScan(basePackages = BPanConstants.BASE_COMPONENT_SCAN_PATH)
@RestController
@Api(tags = "测试接口类")
@Validated
@MapperScan(basePackages = BPanConstants.BASE_COMPONENT_SCAN_PATH + ".server.modules.**.mapper")
@EnableTransactionManagement
@EnableAsync
@EnableBinding(PanChannels.class)
public class BPanServerLauncher {

    public static void main(String[] args) {
        SpringApplication.run(BPanServerLauncher.class);
    }

    @GetMapping("hello")
    @ApiOperation("你好世界")
    public R<String> hello(@NotBlank(message = "name不能为空") String name) {
        return R.success("hello " + name + "!");
    }

}
